package com.jiutong.meipengdai.views.popwindow;

import android.content.Context;
import android.graphics.drawable.ColorDrawable;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager;
import android.widget.PopupWindow;
import android.widget.TextView;

import com.jiutong.meipengdai.R;

/**
 * 作用:
 * Created by 78 on 2017/6/22.
 */

public class EvaluateChoosePopupWindow implements View.OnClickListener {

    private TextView tvall,tvno,tvdone;
    private OnAllClickLister allClickLister;
    private OnNoClickLister noClickLister;
    private OnDoneClickLister doneClickLister;
    private LayoutInflater layoutInflater;
    private Context mContext;


    //设置透明图0-255 默认100
    private int mPopAlpha = 100;

    //默认点击pop外面dismiss
    private boolean mIsTouchBoundDismiss = true;

    public  EvaluateChoosePopupWindow (Context mContext){
        this.mContext = mContext;
        this.layoutInflater = LayoutInflater.from(mContext);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.tv_evaluata_choose_pop_all:
                allClickLister.onClick();
                tvall.setTextColor(mContext.getResources().getColor(R.color.orange));
                tvno.setTextColor(mContext.getResources().getColor(R.color.defalult_black));
                tvdone.setTextColor(mContext.getResources().getColor(R.color.defalult_black));
                break;
            case R.id.tv_evaluata_choose_pop_no:
                noClickLister.onClick();
                tvall.setTextColor(mContext.getResources().getColor(R.color.defalult_black));
                tvno.setTextColor(mContext.getResources().getColor(R.color.orange));
                tvdone.setTextColor(mContext.getResources().getColor(R.color.defalult_black));
                break;
            case R.id.tv_evaluata_choose_pop_done:
                doneClickLister.onClick();
                tvall.setTextColor(mContext.getResources().getColor(R.color.defalult_black));
                tvdone.setTextColor(mContext.getResources().getColor(R.color.orange));
                tvno.setTextColor(mContext.getResources().getColor(R.color.defalult_black));
                break;
        }
    }

    public void initView() {
        View v = layoutInflater.inflate(R.layout.evaluate_choose_pop,null);
        tvall = (TextView)v.findViewById(R.id.tv_evaluata_choose_pop_all);
        tvno = (TextView)v.findViewById(R.id.tv_evaluata_choose_pop_no);
        tvdone = (TextView)v.findViewById(R.id.tv_evaluata_choose_pop_done);

        initEvent();
    }

    public void initEvent() {
        tvall.setOnClickListener(this);
        tvno.setOnClickListener(this);
        tvdone.setOnClickListener(this);
    }

    public void setmPopAlpha(int alpha) {
        this.mPopAlpha = alpha;
    }


    /**
     * 点击外面部分是否消失
     *
     * @param isTouchBoundDismiss
     */
    public void setTouchBoundDismiss(boolean isTouchBoundDismiss) {
        mIsTouchBoundDismiss = isTouchBoundDismiss;
    }



    public void setOnAllClickLister(OnAllClickLister lister){
        this.allClickLister = lister;
    }


    public interface OnAllClickLister{
        void onClick();
    }

    public void setOnNoClickLister(OnNoClickLister lister){
        this.noClickLister = lister;
    }


    public interface OnNoClickLister{
        void onClick();
    }

    public void setOnDoneClickLister(OnDoneClickLister lister){
        this.doneClickLister = lister;
    }


    public interface OnDoneClickLister{
        void onClick();
    }


}
